#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

map<int, int> wz;
struct node
{
    int num;
    int pd;
} t[1000050];

bool cmp(node a, node b)
{
    if (a.num == b.num)
    {
        return a.pd < b.pd;
    }
    return a.num > b.num;
}

int main()
{
    int n, cnt = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        int s, sum = 1;
        scanf("%d", &s);
        while (s)
        {
            sum *= (s % 10);
            s /= 10;
        }
        if (wz[sum])
        {
            t[wz[sum]].num++;
        }
        else
        {
            t[++cnt].num = 1;
            t[cnt].pd = sum;
            wz[sum] = cnt;
        }
    }
    sort(t + 1, t + cnt + 1, cmp);
    printf("%d %d", cnt, t[1].pd);
}